package com.ustze.ocr.enums;

import com.ustze.ocr.domain.AliOcrResponse;
import com.ustze.ocr.domain.DispatchPdfBuild;
import com.ustze.ocr.domain.TencentDispatchPdfBuild;
import com.ustze.ocr.domain.vo.DispatchDetailVo;
import com.ustze.ocr.type.tencent.vo.TencentResponse;
import lombok.AllArgsConstructor;
import lombok.Getter;


import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum DispatchPdfEnum {


    TYPE(0, 1,"工作面", 0, 1,0, DispatchPdfBuild::type, TencentDispatchPdfBuild::type),
    WORK_FACE(1, 2,"工作面", 1, 2,1,  DispatchPdfBuild::face, TencentDispatchPdfBuild::face),
    WORK_NUMBER(2, 3, "班次", 2, 3,2,  DispatchPdfBuild::workNumber,  TencentDispatchPdfBuild::workNumber),
    WORK_NUMBER_DESC(3, 4, "班次内容", 3,4, 3,  DispatchPdfBuild::workNumberDesc,  TencentDispatchPdfBuild::workNumberDesc),
    REMARK(4, 5, "备注", 4, 5,4,  DispatchPdfBuild::remark, TencentDispatchPdfBuild::remark),



    ;


    private final Integer code;

    private final Integer tencentCode;


    private final String desc;

    private final Integer yec;
    /**
     *
     */
    private final Integer tencentYec;

    private final Integer ysc;


    /**
     * 阿里数据组装
     */
    private final BiConsumer<List<AliOcrResponse>, DispatchDetailVo> buildData;

    /**
     * 腾讯数据组装
     */
    private final BiConsumer<List<TencentResponse>, DispatchDetailVo> tencentBuildData;


    public static Boolean getType(Integer ysc, Integer yec) {
        return Stream.of(DispatchPdfEnum.values()).anyMatch(data -> data.getYsc().equals(ysc) && data.getYec().equals(yec));
    }

    public static DispatchPdfEnum getCode(Integer code) {
        return Stream.of(DispatchPdfEnum.values()).filter(data -> data.getCode().equals(code)).findFirst().orElse(null);
    }


    public static DispatchPdfEnum getTencentCode(Integer tencentCode) {
        return Stream.of(DispatchPdfEnum.values()).filter(data -> data.getTencentCode().equals(tencentCode)).findFirst().orElse(null);
    }

    public static Boolean ofTencentType(Integer ysc, Integer tencentYec) {
        return Stream.of(DispatchPdfEnum.values()).anyMatch(data -> data.getYsc().equals(ysc) && data.getTencentYec().equals(tencentYec));
    }

}
